
layui.use('laydate',function(){
	  var laydate = layui.laydate;
	   
	    laydate.render({
	      elem: '#startTime'
	    });
	    laydate.render({
	        elem: '#endTime'
	      });
		 
	});


layui.use('table', function(){
  var table = layui.table;
 
  //表单重载
  var $ = layui.$, active = {
		    reload: function(){
		    	 var supplierId = $('#supplierId');
		    	 var auditingStatus = $('#auditingStatus');
		      //执行重载    查询
		      table.reload('materialAuditing', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		        }
		        ,where: {
		        	supplierId: supplierId.val(),
		        	auditingStatus: auditingStatus.val()
		        }
		      });
		    }
		  };
  
  
//监听工具条
  table.on('tool(demo)', function(obj){
    var da = obj.data;
    //审核页面
    if(obj.event === 'audit'){
    	layer.open({
    	  title: "原材料采购审核",
  		  type: 2, //设置为iframe
  		  area: ['40%', '57%'],
  		  content: ['addAuditing.html?purchaseId='+da.purchaseId+"&man=1", 'no'] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
  	  }); 
    //查看详情
    } else if(obj.event === 'purchaseDetail'){
    	layer.open({
   		 title: "原材料采购明细",
   		  type: 2, //设置为iframe
   		  area: ['100%', '75%'],
		  offset: '5%'
   		  ,content: ['../PurchaseRawstock/purchaseDetail.html?purchaseId='+da.purchaseId] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
   	  }); 
    }else if(obj.event === 'auditingDetail'){
    	layer.open({
      		 title: "审核记录",
      		  type: 2, //设置为iframe
      		  area: ['100%', '75%'],
      		  offset: '5%'
      		  ,content: ['materialAuditingDetail.html?purchaseId='+da.purchaseId] //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
      	  }); 
       }
  });
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});


layui.use(['form', 'table'], function(){
	  var form = layui.form
	  var table = layui.table
	  var url="../../listenSupplier/findSupplier.action";
	  var data=null;
	  $.post(url,data,function(mes){
		  $.each(mes.data,function(i,item){
				  $("#supplierId").append("<option value="+item.suId+">"+item.suName+"</option>")
				  load();
		  })
	  },"json")
	  
});

function load(){
	var form = layui.form;
	form.render();
}
